home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / libguile / ports.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-15  |  5.4 KB  |  150 lines

  1. /* classes: h_files */
  2.  
  3. #ifndef PORTSH
  4. #define PORTSH
  5. /*    Copyright (C) 1995 Free Software Foundation, Inc.
  6.  * 
  7.  * This program is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 2, or (at your option)
  10.  * any later version.
  11.  * 
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this software; see the file COPYING.  If not, write to
  19.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  *
  21.  * As a special exception, the Free Software Foundation gives permission
  22.  * for additional uses of the text contained in its release of GUILE.
  23.  *
  24.  * The exception is that, if you link the GUILE library with other files
  25.  * to produce an executable, this does not by itself cause the
  26.  * resulting executable to be covered by the GNU General Public License.
  27.  * Your use of that executable is in no way restricted on account of
  28.  * linking the GUILE library code into it.
  29.  *
  30.  * This exception does not however invalidate any other reasons why
  31.  * the executable file might be covered by the GNU General Public License.
  32.  *
  33.  * This exception applies only to the code released by the
  34.  * Free Software Foundation under the name GUILE.  If you copy
  35.  * code from other Free Software Foundation releases into a copy of
  36.  * GUILE, as the General Public License permits, the exception does
  37.  * not apply to the code that you add in this way.  To avoid misleading
  38.  * anyone as to the status of such modified files, you must delete
  39.  * this exception notice from them.
  40.  *
  41.  * If you write modifications of your own for GUILE, it is your choice
  42.  * whether to permit this exception to apply to your modifications.
  43.  * If you do not wish that, delete this exception notice.  
  44.  */
  45.  
  46.  
  47. #include "__scm.h"
  48.  
  49.  
  50.  
  51. struct scm_port_table 
  52. {
  53.   SCM port;            /* Open port.  */
  54.   int revealed;            /* 0 not revealed, > 1 revealed.
  55.                  * Revealed ports do not get GC'd.
  56.                  */
  57. };
  58.  
  59. extern struct scm_port_table *scm_port_table;
  60. extern scm_port_table_size; /* Number of ports in scm_port_table.  */
  61.  
  62.  
  63.  
  64.  
  65. /* PORT FLAGS
  66.  * A set of flags caracterizes a port.
  67.  */
  68. #define SCM_OPN        (1L<<16) /* Is the port open? */
  69. #define SCM_RDNG    (2L<<16) /* Is it a readable port? */
  70. #define SCM_WRTNG    (4L<<16) /* Is it writable? */
  71. #define SCM_BUF0    (8L<<16)
  72. #define SCM_CRDY    (32L<<16) /* Should char-ready? return #t? */
  73.  
  74. /* A mask used to clear the char-ready port flag. */
  75. #define SCM_CUC        0x001fffffL
  76.  
  77. #define SCM_PORTP(x) (TYP7(x)==scm_tc7_port)
  78. #define SCM_OPPORTP(x) (((0x7f | SCM_OPN) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN))
  79. #define SCM_OPINPORTP(x) (((0x7f | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))
  80. #define SCM_OPOUTPORTP(x) (((0x7f | SCM_OPN | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG))
  81. #define SCM_FPORTP(x) (TYP16S(x)==scm_tc7_port)
  82. #define SCM_OPFPORTP(x) (((0xfeff | SCM_OPN) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN))
  83. #define SCM_OPINFPORTP(x) (((0xfeff | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))
  84. #define SCM_OPOUTFPORTP(x) (((0xfeff | SCM_OPN | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG))
  85.  
  86. #define SCM_INPORTP(x) (((0x7f | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_RDNG))
  87. #define SCM_OUTPORTP(x) (((0x7f | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_WRTNG))
  88. #define SCM_OPENP(x) (SCM_OPN & SCM_CAR(x))
  89. #define SCM_CLOSEDP(x) (!OPENP(x))
  90. #define SCM_STREAM(x) ((FILE *)(SCM_CDR(x)))
  91. #define SCM_SETSTREAM SCM_SETCDR
  92. #define SCM_CRDYP(port) (SCM_CAR(port) & SCM_CRDY)
  93. #define SCM_CLRDY(port) {SCM_CAR(port) &= SCM_CUC;}
  94. #define SCM_CGETUN(port) ((int)SCM_SRS(SCM_CAR(port), 22))
  95. #define SCM_CUNGET(c, port) {SCM_CAR(port) += ((long)c<<22) + SCM_CRDY;}
  96.  
  97.  
  98.  
  99. extern scm_ptobfuns *scm_ptobs;
  100. extern sizet scm_numptob;
  101. extern int scm_port_table_room;
  102.  
  103.  
  104. #ifdef __STDC__
  105. extern void scm_add_to_port_table (SCM port);
  106. extern void scm_remove_from_port_table (SCM port);
  107. extern SCM scm_pt_size (void);
  108. extern SCM scm_pt_member (SCM member);
  109. extern SCM scm_close_all_ports_except (SCM ports);
  110. extern int scm_revealed_count (SCM port);
  111. extern SCM scm_port_revealed (SCM port);
  112. extern SCM scm_set_port_revealed_x (SCM port, SCM rcount);
  113. extern void scm_setfileno (FILE *fs, int fd);
  114. extern void scm_evict_ports (int fd);
  115. extern SCM scm_fdes_to_ports (SCM fd);
  116. extern SCM scm_close_port (SCM port);
  117. extern SCM scm_input_port_p (SCM x);
  118. extern SCM scm_output_port_p (SCM x);
  119. extern void scm_prinport (SCM exp, SCM port, char *type);
  120. extern void scm_ports_prehistory (void);
  121. extern void scm_init_ports (void);
  122.  
  123. #else /* STDC */
  124. extern void scm_add_to_port_table ();
  125. extern void scm_remove_from_port_table ();
  126. extern SCM scm_pt_size ();
  127. extern SCM scm_pt_member ();
  128. extern SCM scm_close_all_ports_except ();
  129. extern int scm_revealed_count ();
  130. extern SCM scm_port_revealed ();
  131. extern SCM scm_set_port_revealed_x ();
  132. extern void scm_setfileno ();
  133. extern void scm_evict_ports ();
  134. extern SCM scm_fdes_to_ports ();
  135. extern SCM scm_close_port ();
  136. extern SCM scm_input_port_p ();
  137. extern SCM scm_output_port_p ();
  138. extern void scm_prinport ();
  139. extern void scm_ports_prehistory ();
  140. extern void scm_init_ports ();
  141.  
  142. #endif /* STDC */
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149. #endif  /* PORTSH */
  150.